We are migrating the bug tracker to github Issues. This is now the preferred way to report NASM bugs.

Self-registration is disabled due to spam issue (mail gorcunov@gmail.com or hpa@zytor.com to create an account)

Bug 3392438 - spurious "assertion output_ins.times >= 0 failed" in a certain file
Summary: spurious "assertion output_ins.times >= 0 failed" in a certain file
Status: CLOSED DUPLICATE of bug 3392437
Alias: None
Product: NASM
Classification: Unclassified
Component: Assembler (show other bugs)
Version: 2.14.xx
Hardware: All All
: Medium normal
Assignee: nobody
URL:
Depends on:
Blocks:
 
Reported: 2017-09-10 16:25 PDT by E. C. Masloch
Modified: 2017-09-27 18:34 PDT (History)
4 users (show)

Obtained from: Binary from nasm.us
Generated by: ---
Bug category:
Observed for: ---
Regression: ---
Regression since:


Attachments
test case that causes the failure (19.24 KB, application/x-7z-compressed)
2017-09-10 16:25 PDT, E. C. Masloch
Details

Note You need to log in before you can comment on or make changes to this bug.
Description E. C. Masloch 2017-09-10 16:25:26 PDT
Created attachment 411614 [details]
test case that causes the failure

Using a non-trivial sample, I receive an error "assertion output_ins.times >= 0 failed" despite there still being 5 bytes available that should be filled with the "times" statement.

Unfortunately, my attempts to simplify the test case have failed, it seems to disappear if the specific conditions aren't met. Thus I'm uploading my entire project that has this error. The first assembling in the following log occurred with the %fatal in line 932 in use; the second assembling is with that %fatal commented. As is visible in the first round, 503 bytes are in use, so as the macro should pad to 508, 5 bytes are left. (TIMES should get 5 as its count.)

$ nasm -v
NASM version 2.14rc0-20170624 compiled on Jun 24 2017
$ FSS=512 SUFFIX= FAT=12; nasm -DNUM=500 -D_DIRBUF_500=1 -D_MEMORY_CONTINUE=1 -D_RPL=0 -D_USE_PART_INFO=0 -D_QUERY_GEOMETRY=1 -D_FAT$FAT=1 boot.asm -o boot${FAT}${SUFFIX}.bin -D_MAP=boot${FAT}${SUFFIX}.map -l boot${FAT}${SUFFIX}.lst -I../lmacros/
lmacros1.mac:404: warning: unterminated string
boot.asm:932: fatal: x = 503
evln@alyra:~/test/nasm/nasmbug$ FSS=512 SUFFIX= FAT=12; nasm -DNUM=500 -D_DIRBUF_500=1 -D_MEMORY_CONTINUE=1 -D_RPL=0 -D_USE_PART_INFO=0 -D_QUERY_GEOMETRY=1 -D_FAT$FAT=1 boot.asm -o boot${FAT}${SUFFIX}.bin -D_MAP=boot${FAT}${SUFFIX}.map -l boot${FAT}${SUFFIX}.lst -I../lmacros/
lmacros1.mac:404: warning: unterminated string
boot.asm:935: panic: assertion output_ins.times >= 0 failed at asm/nasm.c:1342
evln@alyra:~/test/nasm/nasmbug$
Comment 1 E. C. Masloch 2017-09-12 15:20:23 PDT
I've prepared a simpler test case. I'm suspecting that the panic is caused by an early pass when it assembles things in a way that the TIMES value would be negative; eg jumps at first are assembled as near jumps.

$ nasm -v
NASM version 2.14rc0-20170624 compiled on Jun 24 2017
$ echo -ne 'org 0\nstart:\ntimes (508 / 2) jmp fill\nfill:\n%assign i $-$$\n%fatal i\ntimes 508-(fill-start) nop\ndd 0_AA55_0000h\n' > nasmbug.asm
$ nasm -Ox nasmbug.asm -l nasmbug.lst -o nasmbug.bin
nasmbug.asm:6: fatal: 508
$ nasm nasmbug.asm -l nasmbug.lst -o nasmbug.bin
nasmbug.asm:6: fatal: 508
$ echo -ne 'org 0\nstart:\ntimes (508 / 2) jmp fill\nfill:\n%assign i $-$$\n;%fatal i\ntimes 508-(fill-start) nop\ndd 0_AA55_0000h\n' > nasmbug.asm
$ nasm -Ox nasmbug.asm -l nasmbug.lst -o nasmbug.bin
nasmbug.asm:7: panic: assertion output_ins.times >= 0 failed at asm/nasm.c:1342
$ nasm nasmbug.asm -l nasmbug.lst -o nasmbug.bin
nasmbug.asm:7: panic: assertion output_ins.times >= 0 failed at asm/nasm.c:1342
$ nasm -O0 nasmbug.asm -l nasmbug.lst -o nasmbug.bin
nasmbug.asm:7: panic: assertion output_ins.times >= 0 failed at asm/nasm.c:1342
$ echo -ne 'org 0\nstart:\ntimes (500 / 2) jmp fill\nfill:\n%assign i $-$$\n;%fatal i\ntimes 508-(fill-start) nop\ndd 0_AA55_0000h\n' > nasmbug.asm
$ nasm -Ox nasmbug.asm -l nasmbug.lst -o nasmbug.bin
nasmbug.asm:7: panic: assertion output_ins.times >= 0 failed at asm/nasm.c:1342
$ echo -ne 'org 0\nstart:\ntimes (500 / 2) jmp fill\nfill:\n%assign i $-$$\n%fatal i\ntimes 508-(fill-start) nop\ndd 0_AA55_0000h\n' > nasmbug.asm
$ nasm -Ox nasmbug.asm -l nasmbug.lst -o nasmbug.bin
nasmbug.asm:6: fatal: 500
$ 

(Attempts with shorter test cases (ie not 512 bytes of output) have failed as yet. Not sure why.)
Comment 2 H. Peter Anvin 2017-09-27 18:34:14 PDT
*** This bug has been marked as a duplicate of bug 3392437 ***